package ma.jee.portailReservation.service.announce.Impl;

import ma.jee.portailReservation.persistence.announce.Hotel;
import ma.jee.portailReservation.persistence.announce.IHotelDAO;
import ma.jee.portailReservation.service.announce.DisplayHotel;
import ma.jee.portailReservation.service.announce.IDisplayHotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: soufiane
 * Date: 02/01/12
 * Time: 23:50
 * To change this template use File | Settings | File Templates.
 */
@Service("defaultDisplayHotelService")
public class DefaultDisplayHotelService implements IDisplayHotelService{

    @Autowired
	@Qualifier("hibernateHotelDAO")
	private IHotelDAO hotelDAO;

    @Override
    @Transactional(readOnly=true)
    public List<DisplayHotel> getAllDisplayHotels() {

        List<DisplayHotel> result = new ArrayList< DisplayHotel >();

        for(Hotel hotel : hotelDAO.findAll()) {
                  result.add(new DisplayHotel(hotel));
        }

        return result;
    }
}
